home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
SYMBMATH.H06
< prev
next >
Wrap
Text File
|
1994-03-29
|
10KB
|
245 lines
3.1.5. Functions, Procedures and Rules
These are two types of functions: internal and external. The
internal function is compiled into the SymbMath system. The external
function is the library written in SymbMath language, which is
automately loaded when it is needed. (See Chapter 3.4 Library and Package).
The usage of both types are the same. You can change the property or name
of the external function by modifying its library file, or you add a new
external function by creating its library file, but you cannot change the
internal function.
3.1.5.1 Standard Mathematical Functions
Different versions of SymbMath have different number of
standard mathematical functions. The Advanced Version C has all of them.
See the following table in detail for other versions. All below standard
functions, (except for random(x), n!, fac(n) and atan2(x,y)), can be
differentiated and integrated symbolically.
Table 3.1.5.1 Standard Mathematical Functions
-----------------------------------------------------------------------
Functions Meanings
random(x) generate a random number.
n! factorial of n.
fac(n) the same as n!.
sqrt(x) square root, the same as x^0.5.
root(x,n) all n'th root of x.
exp(x) the same as e^x.
sign(x) 1 when re(x) > 0, or both re(x) = 0 and im(x) > 0; 0 when
x=0; -1 otherwise.
abs(x) absolute value of x.
ln(x) natural logarithmic function of x, based on e.
log10(x)
sin(x) sine function of x.
cos(x)
............... above functions in Shareware Version A ...............
tan(x)
csc(x)
sec(x)
cot(x)
asin(x) arc sine function of x, the inverse of sin(x).
acos(x)
atan(x)
acot(x)
asec(x)
acsc(x)
atan2(x,y) the radian angle of (x,y).
............... above functions in Student Version B .................
sinh(x) hyerbolic sine function of x.
cosh(x)
tanh(x)
csch(x)
sech(x)
coth(x)
asinh(x) arc hyerbolic sine function of x, the inverse of sinh(x).
acosh(x)
atanh(x)
acoth(x)
asech(x)
acsch(x)
--------------------------------------------------------------------------
3.1.5.2 Calculus Functions
Calculus functions are for calculus calculation. The first
arguement of the function is for evaluation, and the second arguement
is a varilable that is with repsect to.
Table 3.1.5.2 Calculus Functions
----------------------------------------------------------------------
Functions Meanings
subs(y, x = x0) evaluates y when x = x0.
lim(y, x = x0) gives the limit of y when x approaches x0.
Note that the correct answers usually for the
indeterminate forms: 0/0, inf/inf, 0*inf, 0^0,
inf^0.
d(y, x) differentiate y with respect to x.
d(y, x, order) gives the nth order derivative of y with respect to an
undefined variable x.
d(y) implicit differentiation.
inte(y, x) find the indefinite integral of y with respect to an
undefined variable x.
inte(y,x,a,b) find the definite integral of y with respect to an
undefined variable x taken from x=a to x=b.
inte(y,x,a,b,c) find the definite integral of y with respect to an
undefined variable x taken from x=a to x=b, then to x=c,
where b is singularity.
inte(y, x from a to b) the same as inte(y,x,a,b).
inte(y) implicit integration, used to integrate the
differential equations.
dsolve(y'(x)=f(x,y), y(x), x) solve differential equations.
sum(y, x from xmin to xmax) sum of y step=1.
sum(y, x from xmin to xmax step dx) sum of y.
prod(y, x from xmin to xmax) product of y step=1.
prod(y, x from xmin to xmax step dx) product of y.
---------------------------------------------------------------------
If a second argument x is omitted in the functions d(y)
and inte(y), they are implicit derivatives and integrals. If f(x) is
undefined, d(f(x), x) is differentiation of f(x). These are useful
in the differential and integral equations. (see later chapters).
For examples:
inte(inte(F,x), y) is double integral of F with respect
to both variables x and y.
d(d(y,x),t) is the mixed derivative of y with respect
to x and t.
The keywords "from" "to" "step" "," are the same as separators
in multi-arguement functions. e.g. inte(f(x), x, 0, 1) are the same as
inte(f(x), x from 0 to 1).
Examples:
-------------------------------------------------------------------
differentiation d() d(x^2,x)
integration inte() inte(x^2,x)
limit lim() lim(sin(x)/x, x = 0)
--------------------------------------------------------------------
3.1.5.4 Test Functions
Table 3.1.5.4.1 is*(x) Functions
---------------------------------------------------------------------
Function Meaning
isodd(x) test if x is an odd number.
iseven(x) test if x is an even number.
isinteger(x) test if x is an integer number.
isratio(x) test if x is a rational number.
isreal(x) test if x is a real number.
iscomplex(x) test if x is a complex number.
isnumber(x) test if x is a number.
islist(x) test if x is a list.
isfree(y,x) test if y is free of x.
issame(a,b) test if a is the same as b.
islarger(a,b) test if a is larger than b.
isless(a,b) test if a is less than b.
----------------------------------------------------------------------
All of the is* functions give either 1 if it is true or 0 otherwise.
The type(x) gives the type of x. Its value is a string.
Table 3.1.5.4.2 type(x) functions
--------------------------------------------------
x type(x)
1 "integer"
1.1 "real"
2/3 "ratio"
1+i "complex"
sin(x) "sin()"
[1,2] "[]"
a "symbol"
"a" "string"
a+b "+"
a*b "*"
a^b "^"
a=b "="
a==b "=="
a>b ">"
a>=b ">="
a<b "<"
a<=b "<="
a<>b "<>"
a,b ","
---------------------------------
You also can test x, e.g. if x is type of real number, by
type(x)=="real".
3.1.5.3 Miscellaneous Functions
Table 3.1.5.3 Algebra Functions
---------------------------------------------------------------------
expand(F) expand (a+b)^2 to a^2 + 2*a*b + b^2.
factor(F) factorise a^2 + 2*a*b + b^2 to (a+b)^2.
solve(f(x)=0, x) solve polynomial and systems of linear
equations, or rearrange the equation.
---------------------------------------------------------------------
Note: the Shareware Version has not solve().
For example:
-----------------------------------------------------------
solving solve() solve(x^2+1 = 0, x)
expanding expand() expand((a+b)^2)
factoring factor() factor(a*c+b*c)
-----------------------------------------------------------
where x is an undefined variable.
Conversion functions convert a type of data to another
type of data.
Table 3.1.5.4 Conversion Functions
---------------------------------------------------------------------
listsum([a,b]) convert list to sum.
coef(expr, x^2) gives the coefficient of x^2 in expr.
left(x^2=b) left hand side of an equation.
right(x^2=b) right hand side of an equation.
re(x) real part of complex numbers.
im(x) imaginative part of complex numbers.
num(x) convert x to the floating-point number.
ratio(x) convert x to the rational number.
round(x) convert x to the rounded integer.
trunc(x) convert x to the truncated integer.
----------------------------------------------------------------------
Table 3.1.5.5 The List and Table Functions
----------------------------------------------------------------------
list(f(x), x from xmin to xmax step dx) lists of f(x).
table(f(x), x from xmin to xmax step dx)
data table of function values.
----------------------------------------------------------------------
Above functions can be operated and chained, like the standard
functions.
3.1.5.5 User-defined Functions
You can define the new functions, which include the
standard functions, calculus functions, and algebraic operators.
Define a new function f(x) by
f(x_) := x^2
and then call f(x) as the standard functions. The function name can
be any name, except for some keywords. (for the maximum number of
arguments, see Chapter 7. System Limits).
Clears a variable or function from assignment by
clear(x) # clear x from assignment.
clear(f(x)) # clear f(x) from assignment.
clear(a>0) # clear a>0 from assignment.
Variables can be used in function definitions. It leads to
an important difference between functions and variables. When a
variable is defined, all terms of the definition are evaluated. When
a function is defined, its terms are not evaluated; they are evaluated
when the function is evaluated. That means that if a component of the
function definition is changed, that change will be reflected the next
time the function is evaluated.